const Router = require('koa-router');
const tool = require("../../tools/tool");
const router = new Router();
const {db, Op, QueryTypes} = require("../../models/db");
// 增加退货商品
router.post('/bill/saveBackGoods', async ctx => {
    let user = ctx.user
    let body = ctx.request.body
    let tenantId = user.tenantId;
    try {
        let invId = body.invId;
        let price = body.price;
        let mod = {
            tenantId: tenantId,
            invId: invId,
            price: price
        }
        let model = await db.models['goodsBack'].findOne({
            where: {
                tenantId,
                invId
            }
        })
        if (model) {
            return ctx.err('已存在')
        }
        await db.models['goodsBack'].create(mod)
        return ctx.suc('已保存',)
    } catch (e) {
        return ctx.err(e)
    }
})

module.exports = router;